<template>
  <view>
    <view class="block">
      <view class="list_item">
        <view class="title">收货人姓名:</view>
        <view class="input">{{defaultAddress.receiverName}}</view>
      </view>
      <view class="list_item">
        <view class="title">联系电话:</view>
        <view class="input">{{defaultAddress.receiverMobile}}</view>
      </view>
      <view class="list_item">
        <view class="title">所在地区:</view>
        <view class="input">
          <view>{{ defaultAddress.receiverState }} {{ defaultAddress.receiverCity }}
            {{ defaultAddress.receiverDistrict }} {{defaultAddress.receiverTown}}
          </view>
        </view>
      </view>
      <view class="list_item">
        <view class="title">详细地址:</view>
        <view class="input">{{defaultAddress.receiverAddress}}</view>
      </view>
      <view class="list_item" @click="changeCurrent">
        <view class="qAdd">
          <view>更改收货地址</view>
        </view>
      </view>
    </view>
    <view class="tipBox">
      <label class="macallan-icon mcl-tanhao"></label>温馨提醒：请您不要将未成年人作为订单收件人，或让未成年人接收或接触所购买的酒类商品。
    </view>
    <view class="btn_box" @click="applyGift"><button class="button">确认</button></view>
    <completeStreet v-if="showStreetDialog" operateHandle='gift' @closeStreetDialog='closeStreetDialog'>
    </completeStreet>
  </view>
</template>

<script>
  import tip from '@/utils/tip';
  import api from '@/api/api';
  import {
    CUSTOMER_INFO
  } from '@/utils/constant';
  import completeStreet from './completeStreet.vue'
  // import completeStreet from '@/components/completeStreet/completeStreet.vue'
  export default {
    props: {
      defaultAddress: {
        type: Object
      }
    },
    components: {
      completeStreet
    },
    data() {
      return {
        showStreetDialog: false
      }
    },
    mounted() {
    },
    methods: {
      openStreetDialog(){
          this.showStreetDialog = true
      },
      changeCurrent() {
        this.$emit('setFromPage', 'gift')
        this.$emit('currentPage', 0,'gift');
        // uni.navigateTo({
        //   url:'/pages/customer/address'
        // })
      },
      applyGift() {
        let noStreetDistict = ['东莞市','中山市','儋州市']
        let noStreet = noStreetDistict.indexOf(this.defaultAddress.receiverCity)
        if(!this.defaultAddress.receiverTown && noStreet == -1){
          this.showStreetDialog = true
          return false
        }
        this.$emit('applyGift', this.defaultAddress)
      },
      closeStreetDialog() {
        this.showStreetDialog = false
        this.$emit('setFromPage', 'gift')
        setTimeout(() => {
          this.$emit('currentPage', 2, this.defaultAddress.customerAddressId);
        }, 50)
      },
    }
  }
</script>

<style lang="scss">
  .block {
    background: #fff;
  }

  .list_item {
    display: flex;
    align-items: center;
    border-top: 1px solid #efefef;
    padding: 35rpx 20rpx;

    .qAdd {
      text-align: center;
      width: 100%;
      padding: 8rpx 0;
    }

    .title {
      margin-right: 20rpx;
    }

    .input {
      flex: 1;

      input {
        color: #666666;
        font-size: 26rpx;
      }
    }
  }

  .btn_box {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 30rpx;
    margin: 0 24rpx;

    .button {

      background: #000;
    }
  }


  .tipBox {
    padding: 26rpx 20rpx 0;

    .labeltext {
      margin-top: 15rpx;
      text-align: justify;
      font-weight: 24rpx;
      line-height: 38rpx;

      .circle {
        display: inline-block;
        border: 1px solid #000;
        border-radius: 50%;
        width: 26rpx;
        height: 26rpx;
        line-height: 28rpx;
        text-align: center;
        font-size: 22rpx;
        margin-right: 4rpx;
      }
    }
  }
</style>
